<template>
	<view class="main">
		<u-navbar back-text="" slot="center" @leftClick="navBack()" safeAreaInsetTop placeholder>
			<view slot="center" class="leftText">{{cardInfo.nickName}}</view>
		</u-navbar>
		<!--list start-->
		<view class="master-infoTiele">
			<view class="master-item">
				<view class="master-faceItem poser dis-row">
					<!--头像处理start-->
					<view class="faceItem-ico">
						<image :src="cardInfo.avatar?cardInfo.avatar:'http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/default-avatar.png'"></image>
					</view>
					<!--头像处理over-->
					<!--顶部右侧标题文字开始-->
					<view class="faceText dis-clm">
						<!--置顶信息start-->
						<view class="faceText-t1 dis-row">
							<view class="master-name">{{cardInfo.nickName}}</view>
							<block v-if="cardInfo.realName">
								<label><image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/user-real.svg"></image></label>
								<text>实名认证</text>
							</block>
						</view>
						<!--置顶信息over-->
						<view class="master-userinfo dis-row">
							<text v-if="cardInfo.gender">{{cardInfo.gender==1?'男':'女'}}</text>
							<text v-if="cardInfo.age">{{cardInfo.age}}岁</text>
							<text v-if="cardInfo.nationStr">{{cardInfo.nationStr}}</text>
						</view>
					</view>
					<!--顶部右侧标题文字结束-->
					<!--是否在线开始-->
					<view class="const-an" v-if="cardInfo.status!==null">
						<text v-if="cardInfo.status===0">找活中</text>
						<text v-if="cardInfo.status===1">暂不找活</text>
						<text v-if="cardInfo.status===2">有活预定下一个</text>
					</view>
					<!--是否在线结束-->
				</view>
				<!--标签列表开始-->
			    <view class="contacts-gouceng dis-row">
					<block v-if="cardInfo.staffTypeStr"><label>人员构成</label><text>{{cardInfo.staffTypeStr}}<text v-if="cardInfo.peopleNumStr">({{cardInfo.peopleNumStr}}人)</text></text></block>
					<block v-if="cardInfo.workYear"><label>工龄</label><text>{{cardInfo.workYear}}年</text></block>
					<block v-if="cardInfo.masteryStr"><label>熟练度</label><text>{{cardInfo.masteryStr}}</text></block>
				</view>
				<!--标签列表结束-->
			   <view class="contacts-address dis-row poser">
				   <view class="map-ico"><image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/my/ico-address.svg"></image></view>
				   <view class="bt-s dis-row">
				   	<label>陕西西安</label><text>·</text><label>{{cardInfo.updateTime}}</label>
				   </view>
				   <view v-if="cardInfo.status" class="cnt-ico dis-row">
					   <view><label></label></view><text>今日找活中</text>
				   </view>
			   </view>
			</view>
		</view>
		<!--list over-->
		<!--找活期望开始-->
		<view class="cons-infoname v-box dis-clm">
			<view class="t-name">找活期望</view>
			<view class="t-text dis-row" v-if="cardInfo.skills">
				<label>工种</label><text>{{strHandle(cardInfo.skills)}}</text>
			</view>
			<view class="t-text dis-row" v-if="cardInfo.hopeAddr">
				<label>期望地点</label><text>{{strHandle(cardInfo.hopeAddr)}}</text>
			</view>
			<view class="t-text dis-row" v-if="cardInfo.workType1Str">
				<label>长短工</label><text>{{cardInfo.workType1Str}}</text>
			</view>
			<view class="t-text dis-row" v-if="cardInfo.settlementStr">
				<label>结算方式</label>
				<text>{{cardInfo.settlementStr}}</text> 
				<text v-if="cardInfo.salary"> / {{cardInfo.salary}}</text>
				<text v-if="cardInfo.salaryUnitStr">{{cardInfo.salaryUnitStr?cardInfo.salaryUnitStr:'元'}}</text>
			</view>
			<view class="t-textPre" v-if="cardInfo.notice">{{cardInfo.notice}}</view>
			<block v-if="cardInfo.videoUrl">
			<view class="t-name">视频简历</view>
			<view class="t-video">
				<image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/my/1.jpg"></image>
			</view>
			</block>
			<block v-if="cardInfo.productHistoryList && cardInfo.productHistoryList.length>0">
				<view class="t-name">项目经历</view>
				<view class="tx-jingli v-box dis-clm" v-for="(item,index) in cardInfo.productHistoryList" :key="index">
					<view class="jingli-name">{{item.enterpriseName}}</view>
					<view class="jingli-pre dis-row">
						<label>{{strHandle(item.skill)}}</label>
						<text>{{item.startTime}}-{{item.endTime}}</text>
					</view>
					<view class="jingli-info">{{item.remark}}</view>
				</view>
			</block>
			<block v-if="cardInfo.certificateInfoList && cardInfo.certificateInfoList.length>0">
			<view class="t-name" style="margin-bottom: 20rpx;">技能证书</view>
			<view class="contacts-zhengshu dis-row" v-for="(item,index) in cardInfo.certificateInfoList" :key="index">
				<!-- <image :src="item.imgUrl"></image> -->
				<image src="https://xgr.oss-cn-hangzhou.aliyuncs.com/certificate/%E7%BB%84%20133.png"></image>
				
				<view class="zhengshu-text dis-clm">
					<label class="child-label">{{item.cname}}</label>
					<view class="dis-row">
						<label>获得证书时间</label><text>{{item.issueDate}}</text>
					</view>
				</view>
			</view>
			</block>
			<view class="t-name" v-if="cardList && cardList.length>0" style="margin-top: 30rpx;">推荐相似工人</view>
		</view>
		<view style="height: 20rpx; background: #F3F3F3;"></view>
		<!--找活期望结束-->
		<!--list start-->
		<block v-if="cardList && cardList.length>0" style="margin-bottom: 210rpx;">
		<view class="master-block" v-for="(item,index) in cardList" :key="index" @click="JumpNext(item)" v-if="index<2">
			<view class="master-item">
				<view class="master-faceItem poser dis-row">
					<!--头像处理start-->
					<view class="faceItem-ico poser">
						<image :src="item.avatar?item.avatar:'http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/default-avatar.png'"></image>
						<label>{{item.staffTypeStr}}</label>
					</view>
					<!--头像处理over-->
					<!--顶部右侧标题文字开始-->
					<view class="faceText dis-clm">
						<!--置顶信息start-->
						<view class="faceText-t1 dis-row">
							<!-- <view class="zhidding">置顶</view> -->
							<view class="master-name">{{item.nickName}}</view>
							<block v-if="item.isRealName">
								<label><image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/user-real.svg"></image></label>
								<text>实名认证</text>
							</block>
						</view>
						<!--置顶信息over-->
						<view class="master-userinfo dis-row">
							<text v-if="item.gender">
								<block v-if="item.gender==1">男</block>
								<block v-else-if="item.gender==2">女</block>
							</text>
							<text v-if="item.age">{{item.age}}岁</text>
							<text v-if="item.nation">{{item.nation}}</text>
						</view>
					</view>
					<!--顶部右侧标题文字结束-->
					<!--是否在线开始-->
					<view class="master-t3 dis-row" v-if="item.status">
						<view><label></label></view><text>今日找活中</text>
					</view>
					<!--是否在线结束-->
				</view>
				<!--标签列表开始-->
				<view class="bloc-small">
					<label v-if="item.workYear">{{item.workYear}}年工龄</label>
					<label v-if="item.workType1">{{item.workType1}}</label>
					<label v-if="item.mastery">{{item.mastery}}</label>
				</view>
				<view class="block-pre" style="color: #A1A1A1;font-size: 28rpx;">{{item.notice}}</view>
				<!--标签列表结束-->
				<!--底部开始哦-->
				<view class="master-zpList dis-clm poser">
					<view class="zpList-child dis-row">
						<label>期望工种</label><text>{{strHandle(item.skills)}}</text>
					</view>
					<view class="zpList-child dis-row">
						<label>期望地点</label><text>{{strHandle(item.hopeAddr)}}</text>
					</view>
					<view class="zpList-right" v-if="item.salary">
						<view class="zplistrv-s1"><label>{{item.salary}}</label>{{item.salaryUnit?item.salaryUnit:'元'}}</view>
						<view class="zpList-s2">期望薪资</view>
					</view>
				</view>
				<!--底部结束-->
			</view>
		</view>
		</block>
		<view style="height: 140rpx;"></view>
		<!--list over-->
		<!--底部开始-->
		<view class="recd-footer">
			<view class="recd-child dis-row">
				<view class="resc-item dis-clm">
					<button class="share" type="default" open-type="share">
						<image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/recruitmentinfo/shares.svg"></image>
						<text style="line-height: 33rpx; font-size: 28rpx; margin-top: 10rpx;">分享</text>
					</button>
				</view>
				<view class="resc-btns dis-row marginrs dis-clor1" @click="sendInfoMessage">
					<label><image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/recruitmentinfo/rec-info.svg"></image></label>
					<text>发传单</text>
				</view>
				<view class="resc-btns dis-row dis-clor2" @click="sendInfoTel">
					<label><image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/recruitmentinfo/rec-tel.svg"></image></label>
					<text>打电话</text>
				</view>
			</view>
		</view>
		<!--底部结束-->
		
		
		<u-popup :show="Infoshow" :round="10" mode="bottom"  @close="infoclose" @open="infoopen"
		closeIconPos="top-right"
		closeable="true">
		   <view class="person-pop dis-clm">
			   <view class="saixuan-name">请选择发送的招工传单</view>
			   <scroll-view style="height: 800rpx;" scroll-y>
			   <view class="person-lst dis-clm v-box">
				   <view v-for="(item,index) in jobList" @click="changeJob(item)" class="person-item row-box" 
				   :class="jobId==item.orderId?'personActice':''">{{item.title}}</view>
			   </view>
			   </scroll-view>
			   <view class="person-sure" @click="sendMessageInfo">
				   <view>发送</view>
			   </view>
		   </view>
		</u-popup>
	</view>
</template>

<script>
import Index from "@/common/index-model.js"	
let index = new Index()
let that = null
export default {
	data() {
		return {
			Infoshow:false,
			id:0,
			cardInfo:{},
			cardList:[],
			jobId:0,
			jobList:[],
			pagesNum:0
		}
	},
	onLoad(opt) {
		let q=opt.q;
		if(q){
			q=decodeURIComponent(q);
			q=index.UrlParamHash(q);			
			uni.setStorageSync('shareUserId',q.userid);
			this.id=q.id;
		}else{
			uni.setStorageSync('shareUserId',opt.userid);
			this.id=opt.id;
		}
		
		var pages    = getCurrentPages();
		this.pagesNum = pages.length - 2;
		
		this.getPeopleInfo();
		this.getWorkerList();
	},
	onShareAppMessage(res) {
	    if (res.from === 'button') {// 来自页面内分享按钮
	      console.log(res.target)
	    }
	    return {
	      title: '【天下工人】'+this.cardInfo.nickName+'正在找'+this.strHandle(this.cardInfo.skills,',')+'相关的好活',
	      path: '/pagesB/workInfo/RecruitmentInfo?id='+this.id+'&userid='+uni.getStorageSync('userid'),
		  content: '经验：'+this.cardInfo.workYear+'年工龄 期望薪资：'+this.cardInfo.salary+this.cardInfo.salaryUnitStr?this.cardInfo.salaryUnitStr:'元',
		  imageUrl: 'http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20230327160119.png'
		  
	    }
	},
	onShareTimeline(res){
		return {
			title: '【天下工人】'+this.orderinfo.title,
			query: '/pagesB/workInfo/RecruitmentInfo?id='+this.id+'&userid='+uni.getStorageSync('userid'),
			imageUrl: 'http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20230327160119.png'
		}
	},
	methods: {
		//跳转到详情页
		JumpNext(item) {
			index.navigate_to('/pagesB/workInfo/RecruitmentInfo?id='+item.id)
		},
		navBack(){
			if(this.pagesNum<0){
				index.switch_tab('/pages/worker/index')
			}else{
				index.navigate_back();
			}
		},
		getPeopleInfo(){
			index.getPublicUserMember('','client/card/detail/'+this.id,'get',res=>{
				console.log('名片详情数据返回======',res)
				if(res.data.code == 200 && res.data.success){
					this.cardInfo=res.data.result;
				}else if(res.data.code == '401'){
					uni.removeStorageSync('token')
					index.navigate_to('/pagesC/login/login');
				}else{
					index.show_tips('该名片已下线或不存在');
					setTimeout(()=>{
						index.navigate_back();
					},3000)
				}
			})
		},
		//根据条件查询好活列表
		getWorkerList() {
			index.getPublicUserMember({},'/client/recruit/similar/'+this.id,'get',res=>{
				if(res.data.code == 200 && res.data.success){
					this.cardList=res.data.result;
				}
			})
		},
		infoopen() {
			this.Infoshow = true
		},
		infoclose() {
			this.Infoshow = false
		},
		changeJob(item){
			this.jobId=item.orderId;
		},
		sendInfoMessage() {
			let url="/client/job/recruitment/management"
			index.getPublicUserMember({status:0},url,'get',res=>{
				if(res.data.code==200 && res.data.result && res.data.result.length>0){
					this.jobList=res.data.result;
					this.Infoshow = true
				}else{
					index.show_tips('暂无可发送找活传单');
				}
			})
			
		},
		sendInfoTel() {
			
			if(this.cardInfo.hxName==uni.getStorageSync('hxuser')){
				index.show_tips('您不能给自己拨打电话');return false;
			}
			if(!uni.getStorageSync('token')){
			    let url="../../pagesC/login/login"
			    index.navigate_to(url)
			    return false
			}
			// uni.makePhoneCall({
			// 			phoneNumber: this.cardInfo.mobile
			// });
			let url="/secret/call/secretNumber"
			index.getPublicUserMember({targetId:this.cardInfo.userId},url,'POST',res=>{
				if(res.data.code==200){
					uni.makePhoneCall({
						phoneNumber: res.data.result
					});
				}else if(res.data.code == 100017){
					index.show_tips('请完善您的个人信息')
					setTimeout(()=>{
						index.navigate_to('/pagesC/my/MyEditUserInfo');
					},2000)
				}
			})
		},
		sendMessageInfo() {
			if(!this.jobId){
				index.show_tips('请选择您要发送的传单');return false;
			}
			if(this.cardInfo.hxName==uni.getStorageSync('hxuser')){
				index.show_tips('您不能给自己发送传单');return false;
			}
			let send={
				"targetId":this.cardInfo.userId,
				"orderId":this.jobId
			}
			index.getPublicUserMember(send,'client/public/add/contact','post',res=>{
				if(res.data.code == 200 && res.data.success){
					this.goMessage(res.data.result);
					this.Infoshow = false
				}else{
					index.show_tips(res.data.message)
					return false
				}
				this.Infoshow = false
			})
			index.navigate_to('./Collectleaflets')
		},
		goMessage(data){
			let url;
			// if(data.canSend==1){
			// 	url='/pagesB/hxIm/index?user='+this.cardInfo.hxName;
			// }else{
			// 	url='/pagesB/hxIm/index?user='+this.cardInfo.hxName+'&orderid='+this.jobId+"&type=hh";
			// }
			url='/pagesB/hxIm/index?user='+this.cardInfo.hxName+'&orderid='+this.jobId+"&type=hh";
			index.navigate_to(url)
		},
		strHandle(str,char=','){
			str=index.strTrim(str,char);
			return index.strRep(str,',','、');
		}
	}
}
</script>
<style>
	page{
		background: #f3f3f3;
	}
</style>
<style scoped>
@import url("@/static/css/publics.css");
@import url("@/static/css/RecruitmentInfo.css");	
.share{
	padding: 0; border: 1px #F8F8F8 solid; font-size: 0rpx; color: #3D3D3D;
}
.share::after{border:none;}
</style>